﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class wjzx_Member_Operation : System.Web.UI.Page
{
    string Pwd;
    protected void Page_Load(object sender, EventArgs e)
    {
        AdminCs.CheckLoginState();
        if (!IsPostBack)
        {
            pro_txt();
             if (Request.QueryString["us"] == "del")　//删除信息
            {
                del_user();
            }
        }
    }

    public void del_user()//删除信息
    {
        int id = int.Parse(Request.QueryString["ID"]);
        string sql = "delete  wj_User where wj_ID=" + id;
        Class1.ExecSql(sql);
        Class1.AlertShow("删除成功！", "Member_Manage.aspx");
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        Md5Pw md5 = new Md5Pw();//MD5加密
        int id = int.Parse(Request.QueryString["ID"]);
        string UserName = TextBox1.Text.Trim();

        string UserPwd = TextBox2.Text.Trim();
        if (UserPwd != "")
        {
             Pwd = md5.Md5(UserPwd);
        }
        else
        {
            DataTable dt = Class1.ExecSel("select * from wj_User where wj_ID='" + id + "'");
            Pwd = Convert.ToString(dt.Rows[0]["wj_UserPwd"]);
        }
        string Questions = TextBox4.Text.Trim();
        string Answer = TextBox5.Text.Trim();
        string Email = TextBox6.Text.Trim();
        string Sex = RadioButtonList1.SelectedValue;

        
        

        string sql = ("update wj_User set wj_User='" + UserName + "',wj_UserPwd='" + Pwd + "',wj_Questions='" + Questions + "',wj_Answer='" + Answer + "',wj_Email='" + Email + "',wj_Sex='" + Sex + "' where wj_ID=" + id + "");
        Class1.ExecSql(sql);
        Class1.AlertShow("修改成功！", "Member_Manage.aspx");


    }
    public void pro_txt()//显示修改的文本信息
    {
        int id = int.Parse(Request.QueryString["ID"]);
        DataTable dt = Class1.ExecSel("select * from wj_User where wj_ID='" + id + "'");
        TextBox1.Text = Convert.ToString(dt.Rows[0]["wj_User"]);
        //TextBox2.Text = Convert.ToString(dt.Rows[0]["wj_UserPwd"]);
        TextBox4.Text = Convert.ToString(dt.Rows[0]["wj_Questions"]);
        TextBox5.Text = Convert.ToString(dt.Rows[0]["wj_Answer"]);
        TextBox6.Text = Convert.ToString(dt.Rows[0]["wj_Email"]);
        if (dt.Rows[0]["wj_Sex"].ToString() == "男")
        {
            this.RadioButtonList1.Items[0].Selected = true;
            this.RadioButtonList1.Items[1].Selected = false;
        }
        if (dt.Rows[0]["wj_Sex"].ToString() == "女")
        {
            this.RadioButtonList1.Items[0].Selected = false;
            this.RadioButtonList1.Items[1].Selected = true;
        }
    }
}
